package com.tanhua.server.controller;

import com.tanhua.model.vo.NearUserVo;
import com.tanhua.model.vo.PageResult;
import com.tanhua.model.vo.RecommendUserQueryParam;
import com.tanhua.model.vo.TodayBest;
import com.tanhua.server.service.TanhuaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/tanhua")
public class TanhuaController {

    @Autowired
    private TanhuaService tanhuaService;

    /**
     * 今日佳人
     * @return
     */
    @GetMapping("/todayBest")
    public ResponseEntity todayBest(){
        TodayBest todayBest = tanhuaService.todayBest();
        return ResponseEntity.ok(todayBest);
    }

    /**
     * 首页好友推荐
     * @param queryParam
     * @return
     */
    @GetMapping("/recommendation")
    public ResponseEntity recommendation(RecommendUserQueryParam queryParam){
        PageResult<TodayBest> pageResult = tanhuaService.recommendation(queryParam);
        return ResponseEntity.ok(pageResult);
    }

    /**
     * 查看佳人信息
     * @param userId
     * @return
     */
    @GetMapping("/{userId}/personalInfo")
    public ResponseEntity personalInfo(@PathVariable Long userId){
        TodayBest todayBest = tanhuaService.getUserInfo(userId);
        return ResponseEntity.ok(todayBest);
    }

    /**
     * 查看佳人的陌生人问题
     * @param userId
     * @return
     */
    @GetMapping("/strangerQuestions")
    public ResponseEntity strangerQuestions(Long userId){
        String txt = tanhuaService.strangerQuestions(userId);
        return ResponseEntity.ok(txt);
    }

    /**
     * 回复佳人的陌生人问题
     * @return
     */
    @PostMapping("/strangerQuestions")
    public ResponseEntity replyStrangerQuestions(@RequestBody Map<String,Object> paramMap){
        tanhuaService.replyStrangerQuestions(paramMap);
        return ResponseEntity.ok(null);
    }

    /**
     * 探花 列表
     * @return
     */
    @GetMapping("/cards")
    public ResponseEntity cards(){
        List<TodayBest> voList = tanhuaService.cards();
        return ResponseEntity.ok(voList);
    }

    /**
     * 探花 - 右滑 喜欢
     * @param userId
     * @return
     */
    @GetMapping("/{userId}/love")
    public ResponseEntity love(@PathVariable Long userId){
        tanhuaService.love(userId);
        return ResponseEntity.ok(null);
    }

    /**
     * 探花 - 左滑 不喜欢
     * @param userId
     * @return
     */
    @GetMapping("/{userId}/unlove")
    public ResponseEntity unlove(@PathVariable Long userId){
        tanhuaService.unlove(userId);
        return ResponseEntity.ok(null);
    }

/**
 * 搜附近
 * @param gender
 * @param distance
 * @return
 */
@GetMapping("/search")
public ResponseEntity searchNearBy(String gender, Long distance){
    List<NearUserVo> list = tanhuaService.searchNearBy(gender, distance);
    return ResponseEntity.ok(list);
}
}
